# # # -*- coding: utf-8 -*-
# # # 定义一个字典
# # dic = {'剧情': 11, '犯罪': 10, '动作': 8, '爱情': 3, '喜剧': 2, '冒险': 2, '悬疑': 2, '惊悚': 2, '奇幻': 1}
# # #通过list将字典中的keys和values转化为列表
# # keys = list(dic.keys())
# # values = list(dic.values())
# # # 结果输出
# # print("keys列表为：",end='')
# # print(keys)
# # print("values列表为：",end='')
# # print(values)
# import pandas as pd
#
# # aa = [{"name":"zhangkai", "age":12}, {"name":"zhangkai", "age":13}, {"name":"heh", "age":19}]
#
# # df = pd.DataFrame([["zhangkai", 12], ["zhangkai", 13], ["heh", 19]])
# # df.columns = ["name", "age"]
# # new_df = df.drop_duplicates(subset=["name"])
# # name_lin = None
# # result_list = []
# # for i in new_df.itertuples():
# #     result_dict = dict()
# #     name = getattr(i, "name")
# #     data = df[df["name"] == name]
# #     data_value = data.values
# #     ages = 0
# #     for lin in data_value:
# #         name_lin = lin[0]
# #         ages += lin[1]
# #     result_dict[name_lin] = ages
# #     result_list.append(result_dict)
# # print(result_list)
#
# def DelRepeat(data,key):
#   new_data = [] # 用于存储去重后的list
#   values = []  # 用于存储当前已有的值
#   for d in data:
#     if d[key] not in values:
#       new_data.append(d)
#       values.append(d[key])
#   return new_data
#
# def processing_data(data_list, Mname):
#     result_list = []
#     new_data_list = DelRepeat(data_list, Mname)
#     for obj in new_data_list:
#         result_dict = {}
#         data_obj = [x for x in data_list if x.get("name") == obj.get("name")]
#         name = ""
#         all_num = 0
#         for new_obj in data_obj:
#             name = new_obj.get('name')
#             all_num += new_obj.get('age')
#         result_dict["name"] = name
#         result_dict["age"] = all_num
#         result_list.append(result_dict)
#     return result_list
#
# # data_list = [{"name":"heh", "age":19}, {"name":"zhangkai", "age":12}, {"name":"zhangkai", "age":13}]
# #
# # aa = processing_data(data_list, "name")
# # print(aa, '======')
# #
# #
# #
# # print(100*0.65/2)
#
# # aa = ['[20160317]雷慧杰', '[20192067]董晓阳', '[20160322]卢春华', '[20160251]王立新', '[20160251]王立新', '[20160251]王立新', '[20160251]王立新', '[20160251]王立新']
# # aa = ["zhang1", "zhang3", "zhang2","zhang1",  "zhang4"]
# #
# # new_list = []
# # name_list = []
# # for x in aa:
# #     row = dict()
# #     if x in name_list:
# #         for obj in new_list:
# #             if x == obj.get("name"):
# #                 obj["num"] = obj.get("num") + 1
# #         continue
# #     row["name"] = x
# #     row["num"] = 1
# #     name_list.append(x)
# #     new_list.append(row)
# # print(new_list)
#
#
#
# aa = [{"s_name":"zhangkai", "t_name":"xc"}, {"s_name":"zhangkai", "t_name":"lc"}, {"s_name":"zhangkai", "t_name":"lc"}, {"s_name":"hehe", "t_name":"wqw"}]
#
# cc = []
# s_name_list = []
# for x in aa:
#     row = dict()
#     row["s_name"] = x.get("s_name")
#     t_name_list = [y.get("t_name") for y in aa if x.get("s_name") == y.get("s_name")]
#     row["s_num"] = len(list(set(t_name_list)))
#
#     teacher_list = []
#     name_list = []
#     for z in t_name_list:
#         tmp = dict()
#         if z in name_list:
#             for obj in teacher_list:
#                 if z == obj.get("teacher_name"):
#                     obj["class_num"] = obj.get("class_num") + 1
#             continue
#         tmp["teacher_name"] = z
#         tmp["class_num"] = 1
#         teacher_list.append(tmp)
#         name_list.append(z)
#
#     if x.get("s_name") in s_name_list:
#         continue
#     row['teacher_list'] = teacher_list
#     s_name_list.append(x.get("s_name"))
#     cc.append(row)
#
# print(cc)
#
#
#
#
# [
#     {
#         "s_name":"zhangkai",
#         "t_name_list":[
#             {"t_name":"lc", "t_num":2}
#         ]
#     }
# ]

# aa = [{"name":"123", "age":10}, {"name":"z", "age":10}]
# for x in aa:
#     print(x.get("name"))
# aa = ['123', '123', '123', '2', 'zhangkai', '123', '123', '123']
# if "123" in aa:
#     print(555)
# print(round(2.44, 1))
# import os
# def del_file_one(del_file):
#     try:
#         os.remove(del_file)
#         print("文件删除完毕")
#     except(FileNotFoundError):
#         print("文件不存在")
# del_file_one(r"C:\Users\Administrator\Desktop\anyang\anyang\cms\statics\file\images\b52a2e5c-7e2a-11eb-87f7-5cea1d2223b6.jpg")
import os
import requests
# 下载视频到本地

# aa = [{"name":"zhangkai", "age":1}, {"name":"zhangkai", "age":1}]
#
# semester_list = [dict(t) for t in set([tuple(d.items()) for d in aa])]
# print(aa)

aa = [{"name":"zhangkai", "age":1}, {"name":"zhangkai", "age":2}]
# mm = [dict(t) for t in set([tuple(d.get("name").items()) for d in aa])]
# print(mm)
# mm = [{"a":1}, {"b":2}]
# b = []
# c = {}
#

import functools

# def list_dict_duplicate_removal():
#     data_list = [{"name":"zhangkai", "age":1}, {"name":"zhangkai", "age":1}, {"name":"zhangkai", "age":2}]
#     run_function = lambda x, y: x if y in x else x + [y]
#     return functools.reduce(run_function, [[], ] + data_list)
#
#
# if __name__ == '__main__':
#     print(list_dict_duplicate_removal())